package cn.est.controller;

import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author hys
 * @Description
 * @date 2020/1/5 23:47
 * Version 1.0
 */
@RestController
@RequestMapping(value = "/html")
public class TestController {

    private Logger logger = LoggerFactory.getLogger(TestController.class);

    @RequestMapping(value = {"/getTestInfo"}, method = RequestMethod.POST,
            produces = {"application/json;charset=UTF-8"}, consumes = {"application/json;charset=UTF-8"})
    public String getTestInfo(HttpServletRequest request){
        Map<String, Object> resultMap = new HashMap<String, Object>();
        List<Map<String,Object>> lists = new ArrayList<Map<String,Object>>();
        for (int i = 0; i < 3; i++) {
            Map<String, Object> userMap = new HashMap<String, Object>();
            int j = i + 1;
            userMap.put("id", j);
            userMap.put("name", "鲁智深"+j);
            userMap.put("age", 20+j);
            userMap.put("aihao", "看电影"+j);
            lists.add(userMap);
        }
        resultMap.put("content", lists);
        JSONObject resultObj = new JSONObject();
        resultObj.putAll(resultMap);

        logger.debug("调用获取人员信息接口成功");
        System.out.println("调用获取人员信息接口成功");
        return resultObj.toJSONString();
    }
}
